package cn.iocoder.yudao.framework.pay.core.client.impl.pax.model;

import java.util.List;
import javax.validation.constraints.DecimalMax;
import javax.validation.constraints.DecimalMin;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Positive;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.validator.constraints.Length;

@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class PaxCreatePrePayOrderRequest extends PaxRequest {

    @Length(max = 64, message = "merchantTradeNo length must be less than or equal to 64")
    private String merchantTradeNo;

    @NotNull(message = "payChannel cannot be empty")
    private String payChannel;

    @DecimalMin(value = "0.001", message = "orderAmount must be greater than 0.001")
    @NotEmpty(message = "orderAmount cannot be empty")
    private String orderAmount;

    @NotNull(message = "payMethod cannot be empty")
    private String payMethod;

    @NotNull(message = "terminalType cannot be empty")
    private String terminalType;

    @NotEmpty(message = "goodsDetails cannot be empty")
    private List<GoodsDetail> goodsDetails;

    @Length(max = 255, message = "goodsDescription length must be less than or equal to 255")
    @NotEmpty(message = "goodsDescription cannot be empty")
    private String goodsDescription;

    @NotNull(message = "currency cannot be empty")
    private String currency;

    @DecimalMax(value = "3600000", message = "orderExpireTime must be less than or equal to 3600000")
    private Long orderExpireTime;

    @NotNull(message = "deviceInfo cannot be empty")
    private DeviceInfo deviceInfo;

    private String expend;

    private String notifyUrl;

    @Override
    public String apiPath() {
        return "/openapi/v1/order/create";
    }

    // GoodsDetail类定义
    @Data
    public static class GoodsDetail {
        @NotNull(message = "goodsType cannot be empty")
        private String goodsType;

        private String goodsCategory;

        @NotEmpty(message = "referenceGoodsId cannot be empty")
        @Length(max = 64, message = "referenceGoodsId length must be less than or equal to 64")
        private String referenceGoodsId;

        @NotEmpty(message = "goodsName cannot be empty")
        @Length(max = 255, message = "goodsName length must be less than or equal to 255")
        private String goodsName;

        @Positive(message = "goodsAmount is not a legal amount")
        private String goodsAmount;
    }

    // DeviceInfo类定义
    @Data
    public static class DeviceInfo {

        private String deviceType;

        @NotEmpty(message = "deviceIp cannot be empty")
        private String deviceIp;

    }

    // Expend扩展参数，terminalType=WEB时
    @Data
    public static class WebExpend {
        private String returnUrl;

        private String cancelUrl;
    }

    // Expend扩展参数，terminalType=MINI_PROGRAM时
    @Data
    public static class MiniProgramExpend {
        @NotEmpty(message = "miniProgramAppId cannot be empty")
        @Length(max = 255, message = "miniProgramAppId length must be less than or equal to 255")
        private String miniProgramAppId;
    }


}
